var request = require('superagent');

module.exports = function getSidCode(opt){

  request.get(opt.loginedUrl)
    .end(function(res){

      var sidReg,
        sid;

      if(res.ok){
        sidReg = /"sid":"(.+?)"/;
        sid = res.text.match(sidReg);

        opt.backData.sid = sid[1];
      }else{
        opt.backData.errorMsg = res.text;
      };

      if(typeof opt.callback == 'function'){
        opt.callback();
      };

    });
};